home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / emsarray.zip / README < prev   
Text File  |  1992-11-01  |  6KB  |  138 lines

  1.     Array in Expand Memory object For Turbo Pascal 6.0  (Ver. 1.0)
  2.  
  3.                     Written by Jialong He
  4.  
  5.                          15-Oct-92
  6.  
  7. This program allows you to define any array in the Expand Memory and access
  8. the array directly. It is a by-product when I worked on my Ph.D project.
  9. You may freely distribute it or use it for any purpose, provided this notice
  10. is attached with it. I would be very happy if you intend to use it in your
  11. program. Please let me know if you like it.
  12.  
  13. InterNet:
  14.           jialong@neuro.informatik.uni-ulm.de
  15.  
  16. 1. Introduction
  17.    ------------
  18.  DOS has a 640 Kb memory barrier. When there is a large amount of data,
  19.  a programmer has to process data separately by reading only part of the data
  20.  into memory each time. This makes programming very complicated and
  21.  will degrade the program's performance. Now you can put your data into
  22.  expanded memory by including this unit into your program. By defining an
  23.  array in expanded memory, you can access each element directly similar to
  24.  the way you define an array in the heap memory.
  25.  
  26. 2. What is Expanded Memory?
  27.    ----------------------
  28.  Expanded memory is the memory beyond DOS's 640K-byte limit.  The LIM
  29.  specification supports up to 32M bytes of expanded memory.  Because
  30.  the 8086, 8088, and 80286 (in real mode) microprocessors can
  31.  physically address only 1M byte of memory, they access expanded memory
  32.  through a window in their physical address range.
  33.  Expanded memory is divided into segments called logical pages.  These
  34.  pages are typically 16K-bytes of memory.  Your computer accesses
  35.  logical pages through a physical block of memory called a page frame.
  36.  The page frame contains multiple physical pages, pages that the
  37.  microprocessor can address directly.  Physical pages are also
  38.  typically 16K bytes of memory.
  39.  
  40.  This page frame serves as a window into expanded memory.  Just as your
  41.  computer screen is a window into a large spreadsheet, so the page
  42.  frame is a window into expanded memory.
  43.  
  44.  A logical page of expanded memory can be mapped into (made to appear
  45.  in) any one of the physical pages in the page frame.  Thus, a read or
  46.  write to the physical page actually becomes a read or write to the
  47.  associated logical page.  One logical page can be mapped into the page
  48.  frame for each physical page. The page frame is located above 640K
  49.  bytes.  Normally, only video adapters, network cards, and similar
  50.  devices exist between 640K and 1024K.
  51.  
  52. 3. How to use this EMS object in your program
  53.    ------------------------------------------
  54.      (1)  Include EMS unit in your program's USES statement.
  55.  
  56.      (2)  Define EMS arrays by using EMSArray in Var section similar
  57.           to defining other variables.
  58.  
  59.            Var
  60.                AnyArray : EMSArray;
  61.  
  62.      (3)  Determine if EMM is installed by calling the function:
  63.  
  64.                AnyArray.Ems_Installed
  65.  
  66.            if it returns TRUE, EMM is installed, otherwise EMM is absent,
  67.            and you cannot put your data into EMS. Of course, if you define
  68.            many EMS arrays, only a single check for the existence of EMM
  69.            is necessary.
  70.  
  71.      (4)  Determine if there are enough expanded memory pages for your
  72.           application by using the function:
  73.  
  74.               AnyArray.Pages_Available;
  75.  
  76.           it will return unallocated page numbers (16 kb block). You
  77.           can only allocate memory less than or equal to this value.
  78.  
  79.  
  80.      (5)  Allocate expanded memory pages using the procedure:
  81.  
  82.               AnyArray.Alloc(PageNum);
  83.  
  84.            "PageNum" is the numbers of page you need for the defined
  85.            array. This is similar to getting memory from Heap by using
  86.            New() procedure.
  87.  
  88.      (6) Map a logical pages into a physical page by using the procedure:
  89.  
  90.               AnyArray.MapIn(LogicalNum, PhysicalNum);
  91.  
  92.          There are usually 4 physical numbers, so "PhysicalNum" can be
  93.          0, 1, 2, or 3. Suppose you allocate 10 pages (10 * 16 kb in
  94.          size) using AnyArray.Alloc(10), the "LogicalNum" can be any
  95.          value from 0 to 9. Remember, all pages are counted from 0.
  96.  
  97.        Note: If you intend to map more than one logical page into
  98.           different physical pages, I suggest to map them in reverse
  99.           sequence in order to access them continually.
  100.  
  101.             For example: map in 4 pages (64 kb)
  102.  
  103.               AnyArray.MapIn(4, 3);
  104.               AnyArray.MapIn(3, 2);
  105.               AnyArray.MapIn(2, 1);
  106.               AnyArray.MapIn(1, 0);
  107.           In this case, the array index 1 is the first element in
  108.           logical page 1. (You can not access logical page 0 at
  109.           the moment)
  110.  
  111.      (7)  Read/write the data in expanded memory, just as if it were
  112.           conventional memory.
  113.  
  114.             For example:
  115.  
  116.              AnyArray.ByteArry^[ Index ] := 234;    { As Byte Array }
  117.              AnyArray.IntArry^[ Index ]  := 12345;  { As Integer Array }
  118.              AnyArray.RealArry^[ Index ] := 3.5;    { As Real Array }
  119.  
  120.      (8)  Release array memory when you do not need it any more by using
  121.           procedure
  122.  
  123.               AnyArray.Release
  124.  
  125.  
  126.   You may explore the example program EMSTEST.PAS to learn how to
  127.   use EMS objects.
  128.  
  129. 4. File list
  130.    ---------
  131.  
  132.      README              { This file }
  133.      EMS.PAS             { Source Code of EMS object }
  134.      EMS.TPU             { Compiled version of EMS object }
  135.      EMSTEST.PAS         { Example program of using EMS object }
  136.      EMSTEST.EXE         { Executable file of EMSTEST.PAS }
  137.  
  138.